//
//  MBMessageViewController.m
//  MemberBusiness-ios
//
//  Created by cherry pu on 2018/4/23.
//  Copyright © 2018年 zhangXin. All rights reserved.
//

#import "MBMessageViewController.h"
#import "MBLoginViewController.h"
#import "MBMessageTableViewCell.h"

@interface MBMessageViewController ()

@end

@implementation MBMessageViewController
@dynamic viewModel;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupLayout];
    
    [self setUpData];
}

-(void)setupLayout
{
    [super setupLayout];
    
    self.view.backgroundColor = COLOR_BG;
    
    self.naviView.titleLabel.text = @"消息中心";
    
    [self.naviView setUpBackButton];
    
    [self setUpMjRefresh];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(SCREEN_STATUS_BAR_HEIGHT+44, 0, 0, 0));
    }];
    
    @weakify(self);
    [[self.naviView.backButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        [self.navigationController popViewControllerAnimated:YES];
    }];
}

-(void)setUpData
{
    [self.viewModel sendRequest:^(bool success) {
        [self hideLoadingViewFooter];
        if (success) {
            [self.tableView reloadData];
        }
    }];
}

-(void)pullTableViewRequestData:(BOOL)isRefresh
{
    if (isRefresh) {
        [self.viewModel initRequestPullPage];
    }
    
    [self setUpData];
}

-(Class)cellClassForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [MBMessageTableViewCell class];
}


@end
